﻿namespace X2OPC.Core.DA
{
    using System;
    using System.Runtime.InteropServices;

    [ComImport, Guid("730F5F0F-55B1-4c81-9E18-FF8A0904E1FA"), ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IOPCSyncIO2
    {
        /// <summary>
        /// 以非同步方式读取OPCGroup内的OPCItem(s)的值，值会在读取硬件的动作结束后以callback的形式传回 
        /// </summary>
        /// <param name="dwSource"></param>
        /// <param name="dwCount"></param>
        /// <param name="phServer"></param>
        /// <param name="ppItemValues"></param>
        /// <param name="ppErrors"></param>
        /// <returns></returns>
        [PreserveSig]
        int Read([In, MarshalAs(UnmanagedType.U4)] OPCDataSource dwSource, [In] int dwCount, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] phServer, out IntPtr ppItemValues, out IntPtr ppErrors);

        /// <summary>
        /// 以非同步方式将值写入OPCGroup内的OPCItem(s) 
        /// </summary>
        /// <param name="dwCount"></param>
        /// <param name="phServer"></param>
        /// <param name="pItemValues"></param>
        /// <param name="ppErrors"></param>
        /// <returns></returns>
        [PreserveSig]
        int Write([In] int dwCount, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] int[] phServer, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] object[] pItemValues, out IntPtr ppErrors);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dwCount"></param>
        /// <param name="phServer"></param>
        /// <param name="pdwMaxAge"></param>
        /// <param name="ppValues"></param>
        /// <param name="ppwQualities"></param>
        /// <param name="ppftTimeStamps"></param>
        /// <param name="ppErrors"></param>
        /// <returns></returns>
        [PreserveSig]
        int ReadMaxAge([In] int dwCount, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] phServer, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] pdwMaxAge, out IntPtr ppValues, out IntPtr ppwQualities, out IntPtr ppftTimeStamps, out IntPtr ppErrors);
        [PreserveSig]
        int WriteVQT([In] int dwCount, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] int[] phServer, [In] IntPtr pItemValues, out IntPtr ppErrors);
    }
}
